package cn.koala.key.stock.controller;

import cn.koala.key.entity.LeaveStock;
import cn.koala.key.stock.domain.dto.LeaveStockDTO;
import cn.koala.key.stock.domain.dto.StockSearch;
import cn.koala.key.stock.service.LeaveStockService;
import cn.ehi.authority.annotation.WebAuthentication;
import cn.seed.common.core.Result;
import cn.seed.common.core.ResultList;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description:出库单
 * @author 32415
 * @time 2019/04/28
 **/
@RestController
@Api(value = "LeaveStock",tags = "出库单")
public class LeaveStockController {

    @Autowired
    private LeaveStockService leaveStockService;

    @ApiOperation(value = "出库查询")
    @GetMapping("/leave-stock")
    @WebAuthentication(systemCode = "KoalaKey",moduleIds = "KOALAKEY_B_00021")
    public Result<ResultList<LeaveStock>> list(StockSearch leaveStockSearch) {
        return leaveStockService.list(leaveStockSearch);
    }

    @ApiOperation(value = "新增/编辑出库单")
    @PostMapping("/leave-stock")
    @WebAuthentication(systemCode = "KoalaKey",moduleIds = "KOALAKEY_B_00022,KOALAKEY_B_00025")
    public Result insertOrUpdate(@RequestBody LeaveStockDTO leaveStockDTO) {
        return leaveStockService.insertOrUpdate(leaveStockDTO);
    }

    @ApiOperation(value = "出库/作废出库单")
    @PutMapping("/leave-stock")
    @WebAuthentication(systemCode = "KoalaKey",moduleIds = "KOALAKEY_B_00023,KOALAKEY_B_00024")
    public Result invalidOrOutStock(String orderNo,Integer status) {
        return leaveStockService.invalidOrOutStock(orderNo,status);
    }
}
